Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Creating a Hierarchy

Because you can make any class a subclass, you can create a hierarchy of classes. QuickDraw 3D represents the hierarchy as an acyclic graph with bidirectional links. This allows any child class to access its parent's class, and any parent class to track and access its child classes.

For example, the following three calls add the hierarchy shown in Figure 7 to the existing QuickDraw 3D hierarchy:

gFooGroupClass =
    Q3XObjectHierarchy_RegisterClass(
        kQ3ShapeTypeGroup,
        kGroupTypeFoo,
        ...);
gBarGroupClass =
    Q3XObjectHierarchy_RegisterClass(
        kGroupTypeFoo,
        kGroupTypeBar,
        ...);
gBazGroupClass =
    Q3XObjectHierarchy_RegisterClass(
        kGroupTypeFoo,
        kGroupTypeBaz,
        ...);

Figure 7 Sample object hierarchy

The depth of an object in a hierarchy is sometimes referred to as its level. In Figure 7 , there are a total of 6 levels in the bar object class A single object class may contain several private data structures, one for each level in that particular class. Access to class data is restricted in that only the owner of the TQX3ObjectClass may access the class private data. A particular class may expose calls for another class to access the class data, or it may call the class methods. This is also true for each instance of each class.

Thus, in the example of Figure 7 the bar class contains private class data and private instance data for Object , Shared , Shape , Group , fooGroup , and bar . The bar class may access only the class methods and instance data at its level, and so on. Each class exposes calls such as the following to access the class or the instance data at its level:

Q3Group_CountObjectsOfType      (exposes a method)
Q3Shape_AddElement              (exposes a method)
Q3Shared_Edited                 (exposes a method and alters the instance)
Q3Object_GetType                (exposes class data)

© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |